package com.example.springgrpc.service;

import io.grpc.stub.StreamObserver;
import net.devh.boot.grpc.server.service.GrpcService;
import org.example.springgrpc.HelloProto;
import org.example.springgrpc.HelloServiceGrpc;

/**
 * @Author : 叶荻风
 * @create : 2024/6/21 17:02
 */
@GrpcService
public class GrpcServerImpl extends HelloServiceGrpc.HelloServiceImplBase {
    @Override
    public void hello(HelloProto.HelloRequest request, StreamObserver<HelloProto.HelloResponse> responseObserver) {
        String username = request.getUsername();
        System.out.println(username);
        HelloProto.HelloResponse response = HelloProto.HelloResponse.newBuilder().setResult("result : " + username).build();
        responseObserver.onNext(response);
        responseObserver.onCompleted();
    }
}
